#include <lpc23xx.h>
#include "lcd.h"
void T0isr (void) __irq; 
void T2isr (void) __irq; 

unsigned int flasher = 0x0000000; 	

int main (void)
{
    
unsigned int delay; //
	/* Reset all GPIO pins to default: primary function */
    PINSEL0 = 0x00000000;
    PINSEL1 = 0x00000000;
    PINSEL2 = 0x00000000;
    PINSEL3 = 0x00000000;
    PINSEL4 = 0x00000000;
    PINSEL5 = 0x00000000;
    PINSEL6 = 0x00000000;
    PINSEL7 = 0x00000000;
    PINSEL8 = 0x00000000;
    PINSEL9 = 0x00000000;
    PINSEL10 = 0x00000000;
    
    IODIR0 = 0x00000000;
    IODIR1 = 0x00000000;
	  IOSET0 = 0x00000000;
    IOSET1 = 0x00000000;
    
    FIO0DIR = 0x00000000;
    FIO1DIR = 0x00000000;
    FIO2DIR = 0x00000000;
    FIO3DIR = 0x00000000;
    FIO4DIR = 0x00000000;
    
    FIO0SET = 0x00000000;
    FIO1SET = 0x00000000;
    FIO2SET = 0x00000000;
    FIO3SET = 0x00000000;
    FIO4SET = 0x00000000;					
    
	lcd_init();
    lcd_clear();
	lcd_print("T"); 
  
   

T0PR 		= 0x00000000;			//Load prescaler
T0TCR 		= 0x00000002;			//Reset counter and prescaler
T0MCR 		= 0x00000003;			//On match reset the counter and generate an interrupt
T0MR0		= 60000000/4;			//Set the cycle time
T0MR1		= 60000000/8;			// Set duty cycle to 50%
T0EMR  		= 0x00000000;			//On match clear MAT1
T0TCR 		= 0x00000001;			//enable timer

PINSEL0     = (3<<12);
PCONP       |= (0x1<<22);           // Power up timer 2
T2PR 		= 0x00000000;			//Load prescaler
T2TCR 		= 0x00000002;			//Reset counter and prescaler
T2MCR 		= 0x00000003;			//On match reset the counter and generate an interrupt
T2MR0		= 60000000/4;			//Set the cycle time
T2MR1		= 60000000/8;			// Set duty cycle to 50%
T2EMR  		= 0x00000042;			//On match clear MAT1
T2TCR 		= 0x00000001;			//enable timer

VICVectAddr4 = (unsigned)T0isr;		//Set the timer ISR vector address
VICVectCntl4 = 0x0000000F;			//Set channel
VICIntEnable |= 0x00000010;			//Enable the interrupt

VICVectAddr26 = (unsigned)T2isr;		//Set the timer ISR vector address
VICVectCntl26 = 0x00000000;			//Set channel
VICIntEnable |= 0x04000000;			//Enable the interrupt

while(1);
}

void T0isr (void) __irq
{
lcd_print("*");

T0IR 		|= 0x00000001;			    //Clear match 2 interrupt
VICVectAddr  = 0x00000000;			  //Dummy write to signal end of interrupt
}
  
void T2isr (void) __irq
{
T2EMR 		|= 0x00000002;			//Set MAT1 high for begining of the cycle    
T2IR 		|= 0x00000001;			    //Clear match 2 interrupt
VICVectAddr  = 0x00000000;			  //Dummy write to signal end of interrupt
}   